package com.keke.select.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.keke.select.service.SelectService;

@WebServlet("/api/getHisEvents")
public class GetHisEvents extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static SelectService service = new SelectService();

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String pageInfo = req.getParameter("pageInfo");
		String data = null;
		if(pageInfo == null)
			data = service.getHisEventsJsonStr();
		else {
			String[] info = pageInfo.split(",");
			data = service.getHisEventsJsonStr(info[0],info[1]);
		}
		PrintWriter out =  resp.getWriter();
		out.print(data);
	}

	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}